Component({
  mixins: [],
  data: {
    loading: false,
    listData: [],
    total: 0,
    page: 1,
    pagesize: 5,

  
  },
  props: {},
  didMount() { 
    this.getaty(1);
  },
  didUpdate() {},
  didUnmount() {},
  methods: {
    ohmygod() {
      console.log('clic111111k');
    },
    setLoading() {
      this.setData({
        loading: !this.data.loading
      })
    },
    getPageData(current){
      // my.alert({title:current.detail.value});
      this.getaty(current.detail.value);
    },
    // 列表数据
    getaty(pageNum) {
      var apiurl = 'App.ShopRedsVideo.GetPutList';
      var params = {
        "page": pageNum,
        "pagesize": this.data.pagesize,
      };
      var app = getApp();
      var self = this;
      app.xdapis(apiurl, params, function (e) {
        my.hideLoading();
        // my.alert({ title: JSON.stringify(e) });
        self.setData({
          listData: e.list,
          total: e.page_info.total,
          page: e.page_info.page,
          pagesize: e.page_info.pagesize
        });
      });
    },
    //上架
    handleClick(e){
      var x = e.currentTarget.dataset.x;
      var pid = x.record.videos_id;
      var self = this;
      my.confirm({
        title: '确认',
        content: '确定上架全部投放吗?',
        success: (result) => {
          if (result.confirm) {
            if( pid ){
              var apiurl = 'App.ShopRedsVideo.Put';
                var params = {
                  "videos_id": pid,
                  type:4
                };
                var app = getApp();
                app.xdapis(apiurl, params, function (e) {
                  my.hideLoading();
                  my.alert({ title: '操作成功!' });
                  self.getaty(1);
                });
            }
          }
        }
      });
 
    },
     //下架
    downClick(e){
      var x = e.currentTarget.dataset.x;
      var pid = x.record.videos_put_id;
      var self = this;
      my.confirm({
        title: '确认',
        content: '确定下架全部投放吗?',
        success: (result) => {
          if (result.confirm) {
            if( pid ){
              var apiurl = 'App.ShopRedsVideo.TakeOff';
                var params = {
                  "videos_put_id": pid,
                  type: 0
                };
                var app = getApp();
                app.xdapis(apiurl, params, function (e) {
                  my.hideLoading();
                  my.alert({ title: '操作成功!' });
                  self.getaty(1);
                });
            }
          }
        }
      });
 
    }
  },
});
